/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.account.web.controller;


import com.medusa.gruul.account.api.entity.MemberCardPrivilege;
import com.medusa.gruul.account.model.dto.DeleteMemberCardPrivilegeDto;
import com.medusa.gruul.account.model.dto.InsertMemberCardPrivilegeDto;
import com.medusa.gruul.account.model.dto.MemberCardPrivilegeStatusDto;
import com.medusa.gruul.account.model.dto.UpdateMemberCardPrivilegeDto;
import com.medusa.gruul.account.service.IMemberCardPrivilegeService;
import com.medusa.gruul.common.core.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 会员卡权益表 前端控制器
 * </p>
 *
 * @author zhaokw
 * @since 2020-05-24
 */
@RestController
@RequestMapping("/manager")
public class MemberCardPrivilegeController {

    @Autowired
    private IMemberCardPrivilegeService memberCardPrivilegeService;

    /**
     * @Description pc端获取会员卡权益信息
     * @Author zhaokw
     * @Date 10:29 2020\5\24 0024
     **/
    @GetMapping("/getMemberCardPrivilege")
    @ApiOperation(value = "pc端获取会员卡权益信息")
    public Result getMemberCardPrivilege() {
        List<MemberCardPrivilege> memberCardPrivileges = memberCardPrivilegeService.getMemberCardPrivilege();
        return Result.ok(memberCardPrivileges);
    }

    /**
     * 后台更新权益参数
     *
     * @param
     * @return
     */
    @PostMapping("/updateMemberCardPrivilege")
    @ApiOperation(value = "后台更新权益参数")
    public Result updateMemberCardPrivilege(@RequestBody @Validated UpdateMemberCardPrivilegeDto updateMemberCardPrivilegeDto) {
        memberCardPrivilegeService.updateMemberCardPrivilege(updateMemberCardPrivilegeDto);
        return Result.ok();
    }

    /**
     * 后台开启关闭会员卡权益
     *
     * @param
     * @return
     */
    @PostMapping("/updateMemberCardPrivilegeStatus")
    @ApiOperation(value = "后台开启关闭会员卡权益")
    public Result updateMemberCardPrivilegeStatus(@RequestBody @Validated MemberCardPrivilegeStatusDto memberCardPrivilegeStatusDto) {
        memberCardPrivilegeService.updateMemberCardPrivilegeStatus(memberCardPrivilegeStatusDto);
        return Result.ok();
    }

    /**
     * 后台删除自定义会员卡权益
     *
     * @param
     * @return
     */
    @PostMapping("/deleteMemberCardPrivilege")
    @ApiOperation(value = "后台删除自定义会员卡权益")
    public Result deleteMemberCardPrivilege(@RequestBody @Validated DeleteMemberCardPrivilegeDto deleteMemberCardPrivilegeDto) {
        memberCardPrivilegeService.deleteMemberCardPrivilege(deleteMemberCardPrivilegeDto);
        return Result.ok();
    }

    /**
     * 后台插入自定义权益参数
     *
     * @param
     * @return
     */
    @PostMapping("/insertMemberCardPrivilege")
    @ApiOperation(value = "后台插入自定义权益参数")
    public Result insertMemberCardPrivilege(@RequestBody @Validated InsertMemberCardPrivilegeDto insertMemberCardPrivilegeDto) {
        memberCardPrivilegeService.insertMemberCardPrivilege(insertMemberCardPrivilegeDto);
        return Result.ok();
    }

}
